<template>
  <!-- 容器布局 -->
  <el-container class="container">
    <el-aside width="200px">
      <!-- 侧边栏导航组件 -->
      <side-nav></side-nav>
    </el-aside>
    <el-container >
      <el-header>
        <!-- 头部组件 -->
        <admin-header></admin-header>
      </el-header>
      <el-main>
        <!-- 二级路由容器 -->
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>
<script>
// 引入子组件
import SideNav from '../../component/admin/SideNav'
import Header from '../../component/admin/Header'
export default {
  created () {
    // 判断用户是否是二次登入
    localStorage.getItem('token') ? this.loadData() : this.$router.replace('/login')
  },
  methods: {
    loadData () {
      alert('获取数据渲染')
    }
  },
  components: {
    'side-nav': SideNav,
    'admin-header': Header
  }
}
</script>

<style lang="less" scoped>
.container{
  background-color: #f2f3f5;
}
</style>
